package com.example.zcq.rxjava2retrofitmvp.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.zcq.rxjava2retrofitmvp.R;
import com.example.zcq.rxjava2retrofitmvp.contract.TestContract;
import com.example.zcq.rxjava2retrofitmvp.presenter.TestPresenter;
import com.example.zcq.rxjava2retrofitmvp.constant.Constant;

public class Rxjava2RetrofitMvpActivity extends AppCompatActivity implements View.OnClickListener, TestContract.View {


    /**
     * 输入内容
     */
    private EditText mEt;
    private Button mBtn;
    private TestContract.Presenter presenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rxjava2_retrofit_mvp);
        presenter = new TestPresenter(this);
        initView();
    }

    private void initView() {
        mEt = (EditText) findViewById(R.id.et);
        mBtn = (Button) findViewById(R.id.btn);
        mBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.btn:
                presenter.loadData();


                break;
        }
    }

    @Override
    public void update(String s) {
        Log.w(Constant.TAG, "update: "+s );
        mBtn.setText(s);
    }
}
